package com.sync.data.config.writer;

import com.sync.data.ievent.entity.*;
import lombok.RequiredArgsConstructor;
import org.springframework.batch.item.database.JpaItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.persistence.EntityManagerFactory;

@Configuration
@RequiredArgsConstructor
public class JpaWriterConfiguration {

    private final EntityManagerFactory entityManagerFactoryIevent;

    @Bean("ieventSysUserJpaItemWriter")
    public JpaItemWriter<IeventSysUser> ieventSysUserJpaItemWriter() {
        JpaItemWriter<IeventSysUser> writer = new JpaItemWriter<>();
        writer.setEntityManagerFactory(entityManagerFactoryIevent);
        return writer;
    }

    @Bean("ieventBasePositionJpaItemWriter")
    public JpaItemWriter<IeventBasePosition> ieventBasePositionJpaItemWriter() {
        JpaItemWriter<IeventBasePosition> writer = new JpaItemWriter<>();
        writer.setEntityManagerFactory(entityManagerFactoryIevent);
        return writer;
    }


    @Bean("ieventBaseEmployeeJpaItemWriter")
    public JpaItemWriter<IeventBaseEmployee> ieventBaseEmployeeJpaItemWriter() {
        JpaItemWriter<IeventBaseEmployee> writer = new JpaItemWriter<>();
        writer.setEntityManagerFactory(entityManagerFactoryIevent);
        return writer;
    }

    @Bean("ieventBasePositionEmployeeJpaItemWriter")
    public JpaItemWriter<IeventBasePositionEmployee> ieventBasePositionEmployeeJpaItemWriter() {
        JpaItemWriter<IeventBasePositionEmployee> writer = new JpaItemWriter<>();
        writer.setEntityManagerFactory(entityManagerFactoryIevent);
        return writer;
    }

    @Bean("mtBudgetJpaItemWriter")
    public JpaItemWriter<MtBudget> mtBudgetJpaItemWriter() {
        JpaItemWriter<MtBudget> writer = new JpaItemWriter<>();
        writer.setEntityManagerFactory(entityManagerFactoryIevent);
        return writer;
    }
    @Bean("hcpJpaItemWriter")
    public JpaItemWriter<Hcp> hcpJpaItemWriter() {
        JpaItemWriter<Hcp> writer = new JpaItemWriter<>();
        writer.setEntityManagerFactory(entityManagerFactoryIevent);
        return writer;
    }

    @Bean("mtSpeakerSchemaWriter")
    public JpaItemWriter<MtSpeakerSchema> mtSpeakerSchemaWriter() {
        JpaItemWriter<MtSpeakerSchema> writer = new JpaItemWriter<>();
        writer.setEntityManagerFactory(entityManagerFactoryIevent);
        return writer;
    }

    @Bean("baseCostCenterJpaItemWriter")
    public JpaItemWriter<BaseCostCenter> baseCostCenterJpaItemWriter() {
        JpaItemWriter<BaseCostCenter> writer = new JpaItemWriter<>();
        writer.setEntityManagerFactory(entityManagerFactoryIevent);
        return writer;
    }




}
